package cn.edu.jxust.common.domain.web.api.air;

import cn.edu.jxust.common.domain.dto.AirTypeVo;
import cn.edu.jxust.common.response.Result;
import cn.edu.jxust.core.infrastructure.util.Const;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author QiuKangming
 * @version 1.0
 * @description
 * @since 2020/09/15 14:38
 */

@RequestMapping("/api/airtype")
public interface IAirTypeController {

    /**
     * 增加监测气体
     * @param airTypeVo 气体类型视图对象
     * @param result 绑定结果集
     * @return Result
     */
    @PostMapping
    @RequiresRoles(value = { Const.SUPER_ADMIN, Const.BUREAU_ADMIN }, logical = Logical.OR)
    @RequiresPermissions("airtype:add")
    Result addAirType(@RequestBody @Validated AirTypeVo airTypeVo, BindingResult result);

    /**
     * 根据id删除检测气体
     * @param id 气体类型id号
     * @return Result
     */
    @DeleteMapping("/{id}")
    @RequiresRoles(value = { Const.SUPER_ADMIN, Const.BUREAU_ADMIN }, logical = Logical.OR)
    @RequiresPermissions("airtype:del")
    Result delAirType(@PathVariable("id") @Validated Integer id);

    /**
     * 修改监测气体信息
     * @param airTypeVo 气体类型视图对象
     * @param result 绑定结果集
     * @return Result
     */
    @PutMapping
    @RequiresRoles(value = { Const.SUPER_ADMIN, Const.BUREAU_ADMIN }, logical = Logical.OR)
    @RequiresPermissions("airtype:edit")
    Result modifyAirType(@RequestBody @Validated AirTypeVo airTypeVo, BindingResult result);

    /**
     * 查询检测气体信息列表 or 查询检测气体信息: 按名字查找
     * @param airName 气体名称
     * @param page 第几页
     * @param size 一页几条数据
     * @return Result
     */
    @GetMapping
    @RequiresPermissions("airtype:list")
    Result findAirTypePage(@RequestParam(value = "airName", required = false)String airName,
                           @RequestParam(value = "page", defaultValue = Const.DEFAULT_PAGE_NUMBER) Integer page,
                           @RequestParam(value = "size", defaultValue = Const.DEFAULT_PAGE_SIZE) Integer size);


}
